package com.my.study.designPatterns.iteratorPattern;


public class DinnerMenu implements Menu {


    private MenuItem [] menuItems;

    private static final int MAX_DINNER_MENU_COUNT = 5;

    private int index = 0;

    private int position = 0;

    public DinnerMenu(){

        menuItems = new MenuItem[MAX_DINNER_MENU_COUNT];
        addMenuItem("Pork", false, 40.12, "Delicious");
        addMenuItem("Duck", false, 40.12, "Delicious");
        addMenuItem("Beef", true, 40.12, "Delicious");
        addMenuItem("Chicken", false, 40.12, "Delicious");
        addMenuItem("Fish", true, 40.12, "Delicious");

    }


    public void addMenuItem(String name, Boolean vegetable, Double price, String desp){

        if(index < MAX_DINNER_MENU_COUNT){
            menuItems[index] = new MenuItem(name, vegetable, price, desp);
            index ++;
        }else{
            System.out.println("Sorry menu is full, can not add anymore");
        }
    }


    public Iterator<MenuItem> getDinerMenuIterator(){
        return  new DinnerMenuIterator(menuItems);
    }


    @Override
    public Iterator<MenuItem> createIterator() {
        return new DinnerMenuIterator(menuItems);
    }
}
